package com.livew.utils;

import java.io.Serializable;

/**
 * 
 * @ClassName AjaxResult
 * @author wangdong
 * @Date 2016年1月7日 上午9:34:01
 * @version V1.0
 * @Description 响应的结果对象
 */
public class AjaxResult implements Serializable {

	private static final long serialVersionUID = 1L;

	// 返回结果状态信息
	private String message;

	// 返回结果状态码
	private int statusCode;

	// 是否成功
	private boolean success = true;

	// 返回结果json数据
	private Object data;

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}

	public int getStatusCode() {
		return statusCode;
	}

	public void setStatusCode(int statusCode) {
		this.statusCode = statusCode;
	}

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public Object getData() {
		return data;
	}

	public void setData(Object data) {
		this.data = data;
	}

	/**
	 * 正常结果
	 * 
	 * @param content
	 * @return
	 */
	public static AjaxResult getSuccessResult(String content) {
		AjaxResult result = new AjaxResult();
		result.setStatusCode(200);
		result.setMessage(content);
		return result;
	}

	/**
	 * 错误结果
	 * 
	 * @param content
	 * @return
	 */
	public static AjaxResult getErrorResult(String content) {
		AjaxResult result = new AjaxResult();
		result.setStatusCode(500);
		result.setMessage(content);
		return result;
	}

	/**
	 * 结果
	 * 
	 * @param content
	 * @return
	 */

	public static AjaxResult getResult(int statusCode, String content) {
		AjaxResult result = new AjaxResult();
		result.setStatusCode(statusCode);
		result.setMessage(content);
		return result;
	}
	
	/**
	 * 结果
	 * 
	 * @param content
	 * @return
	 */
	
	public static AjaxResult getResult(Boolean bl, String content) {
		AjaxResult result = new AjaxResult();
		result.setSuccess(bl);
		result.setMessage(content);
		return result;
	}

	/**
	 * 结果
	 * 
	 * @param statusCode
	 * @param content
	 * @param success
	 * @return
	 */
	public static AjaxResult getResult(int statusCode, String content, boolean success) {
		AjaxResult result = new AjaxResult();
		result.setStatusCode(statusCode);
		result.setMessage(content);
		result.setSuccess(success);
		return result;
	}
	
	
	/**
	 * 结果
	 * 
	 * @param bl
	 * @param content
	 * @param obj
	 * @return
	 */
	public static AjaxResult getResult(Boolean bl, String content, Object obj) {
		AjaxResult result = new AjaxResult();
		result.setMessage(content);
		result.setSuccess(bl);
		result.setData(obj);
		return result;
	}
	
	/**
	 * 结果
	 * 
	 * @param data
	 * @return
	 */
	public static AjaxResult getResult(Object data) {
		AjaxResult result = new AjaxResult();
		result.setData(data);
		return result;
	}

	@Override
	public String toString() {
		return "Result [message=" + message + ", statusCode=" + statusCode + ", success=" + success + ", data=" + data
				+ "]";
	}
}
